package org.se.scut.hibernate.dao;

import java.util.List;

import org.se.scut.hibernate.dao.model.LoginInfo;

public class LoginDAO extends BaseDAO<LoginInfo> {

	public LoginInfo find(String userName, String passWord)
	{
		
		List<LoginInfo> loginInfos = list(formatSQLString(userName, passWord));
		if (loginInfos.size() > 0) {
			return loginInfos.get(0);
		}
		return null;
	}
	
	private String formatSQLString(String userName, String passWord)
	{
		String origSQL = "select login from LoginInfo login where " +
				"login.userName = %1$s and login.passWord = %2$s";
		return String.format(origSQL, userName, passWord);
	}
}
